package com.copa.l2341;

import java.util.HashMap;
import java.util.Map;

/**
 * @author copa
 * @createDate 2023-02-16 09:24
 * @function 哈希表法
 */
public class Test2 {

    public int[] numberOfPairs(int[] nums) {
        int[] result = new int[2];
        Map<Integer, Boolean> map = new HashMap<>();
        for (int num : nums) {
            map.put(num, !map.getOrDefault(num, true));
            if (map.get(num)) {
                result[0]++;
            }
        }
        result[1] = nums.length - result[0] * 2;
        return result;
    }

    public static void main(String[] args) {
        int[] nums = {1,3,2,1,3,2,2};
        int[] result = new Test2().numberOfPairs(nums);
        System.out.println(result[0] + ":" + result[1]);
    }
}
